#!/bin/sh

branch="${1}"
shift 1

if [ -z "${branch}" ]
then
    echo "usage:"
    echo "  ${0} <branch> [<options>]"
    exit 1
fi

prev="$(git-branch-current)"
if [ -z "${prev}" ]
then
    echo "can't find current git branch using \`git-branch-current\`"
    exit 2
fi

cdbranch "${branch}" && cdbranch "${prev}" && git merge "${branch}"
